<!DOCTYPE html>
<html>
<head>
	<title>栏目列表</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="__ADMIN__//bootstrap/css/bootstrap.min.css" media="all">
    <link rel="stylesheet" href="__ADMIN__/adminlte/css/AdminLTE.min.css">
    <link rel="stylesheet" href="__ADMIN__/adminlte/css/font-awesome.min.css">
	<style type="text/css">
        .p-operating>a{display: inline-block; color:#999; padding:0 8px;}
        .p-operating>a:hover{color:#3c8dbc;}
        .p-sort{border:1px solid #999; text-align: center; }
	</style>
</head>
<body>
    <div class="panel-body">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
            <i class="fa fa-th"></i>
              <h3 class="box-title">栏目列表</h3>
              <div class="box-tools">
                <div class="input-group input-group-sm" style="width: 150px;">
                    <a href="{:url('add',array('id'=>0))}"  class="btn btn-block btn-social btn-foursquare btn-sm">
                        <i class="fa fa-plus"></i> 增加顶级栏目
                    </a>
                </div>
              </div>
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              <table class="table table-hover">
                <tbody>
                <tr>
                  <th>ID</th>
                  <th>栏目名称</th>
                  <th>所属模型</th>
                  <th>操作</th>
                  <th>隐藏</th>
                  <th>排序</th>
                </tr>
                {volist name="columnResult" id="vo"}

                <tr>
                  <td>{$vo.id}</td>
                  <td> {if condition="$vo['level'] neq 0"} |{/if}
                  <?php echo str_repeat('—',$vo['level'] * 2) ?>
                  {$vo.column_name}
                  </td>
                  <td>
                    {switch name="$vo.template_type"}
                    {case value="0"}单页模型{/case}
                    {case value="1"}文章模型{/case}
                    {case value="2"}产品模型{/case}
                    {default /}留言模型
                    {/switch}

                  </td>
                  <td>
                    <div class="p-operating">
                      {switch name="$vo.template_type"}
                      {case value="0"}<a href="{:url('content/singlepage',array('id'=>$vo.id))}">内容</a>{/case}
                      {case value="1"}<a href="{:url('content/articlelist',array('id'=>$vo.id))}">内容</a>{/case}
                      {case value="2"}<a href="{:url('content/productlist',array('id'=>$vo.id))}">内容</a>{/case}
                      {default /}<a href="{:url('content/messagelist',array('id'=>$vo.id))}">内容</a>
                      {/switch}

                      <a href="{:url('edit',array('id'=>$vo.id))}">编辑</a>
                      <a href="{:url('add',array('id'=>$vo.id))}">增加子栏目</a>
                      <a href="javascript:getDeleteId({$vo.id})">删除</a>
                     <!-- <a href="#">浏览</a>-->
                    </div>
                  </td>
                  <td>
                    {eq name="$vo.is_hidden" value="0"}
                    <span class="label label-default">否</span>
                    {else/}
                    <span class="label label-warning">是</span>
                    {/eq}
                  </td>
                  <td><input type="text" class="p-sort" value="{$vo.sort_order}" onblur="sortOrder({$vo.id},this.value)" size="4"></td>
                </tr>
                {/volist}
              </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
    </div>
    <div class="modal fade" id="modal">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-body">
            <p><span style="color:red;">如有子栏目及文档将一起清空</span>，确认删除吗？</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-primary" onclick="delColumn()">确定</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>  
</body>
<!-- jQuery 2.2.3 -->
<script src="__ADMIN__/plugins/jQuery/jquery-2.2.3.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="__ADMIN__/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
  var id;
  function getDeleteId(columnId) {
       id=columnId;
      console.log(id);
      $("#modal").modal('show');
  }
  function delColumn() {
    location.href="del/id/"+id+".html";
  }
  function sortOrder(columnId,sortOrder) {
      $.post("updateColumnSort",{id:columnId,sort_order:sortOrder},function (data) {
         /*if(data.code==0){
             alert(data.msg);
         }else{
             alert(data.msg);
         }*/
      });
  }
</script>
</html>